<template>
  <div>
    <el-form ref="form" :model="formData" label-width="80px">
      <el-form-item label="订单号">
        <el-input v-model="formData.orderNo"></el-input>
      </el-form-item>
      <el-form-item label="下单时间">
        <el-input v-model="formData.orderTime"></el-input>
      </el-form-item>
      <el-form-item label="联系电话">
        <el-input v-model="formData.phone"></el-input>
      </el-form-item>
      <el-form-item label="收货人">
        <el-input v-model="formData.consignee"></el-input>
      </el-form-item>
      <el-form-item label="送货地址">
        <el-input v-model="formData.deliverAddress"></el-input>
      </el-form-item>

      <el-form-item label="送达时间">
        <el-input v-model="formData.deliveryTime"></el-input>
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="formData.remarks"></el-input>
      </el-form-item>
      <el-form-item label="订单金额">
        <el-input v-model="formData.orderAmount"></el-input>
      </el-form-item>
      <el-form-item label="订单状态">
        <el-input v-model="formData.orderState"></el-input>
      </el-form-item>
      <el-button type="primary" @click="btn">确认修改</el-button>
    </el-form>
  </div>
</template>

<script>
import { editOrderReq, getOrderDetailReq } from "@/api/order";
export default {
  data() {
    return {
      formData: {
        id: 0,
        orderNo: "",
        orderTime: "",
        phone: "",
        consignee: "",
        deliverAddress: "",
        deliveryTime: "",
        remarks: "",
        orderAmount: "",
        orderState: "",
      },

      id: "",
      //数据占位
      detail: {},
    };
  },
  methods: {
    async getData() {
      let res = await getOrderDetailReq({ id: this.id });
      let { data, msg } = res.data;
      this.formData = data;
      //数据赋值
      this.detail = res.data.data;
    },
    async btn() {
       
      let res = await editOrderReq({...this.formData})
      console.log(res);
      this.getData()
    },
  },
  created() {
    this.id = this.$route.params.id;
    this.getData();
  },
};
</script>

<style lang="scss" scoped></style>
